import { onUnmounted, reactive, toRefs, watch ,ref} from 'vue';
export  const sysHasMaskAuth = ()=>{
  let sysHasMaskAuth = false;
  if (window.Funcs&&window.Funcs.HasMaskAuth) {
    sysHasMaskAuth = Funcs.HasMaskAuth()
  }
  return sysHasMaskAuth
}
function useMark(mappingProps,labelFields,IsMasked) {
  // const IsMasked = ref(false)
  const initMask = () => {
    if (mappingProps.isDevEnv) {
      return mappingProps.enableMask
    }
    let sysEnableMask = false;
    if (window.Funcs&&Funcs.EnableMask) {
      sysEnableMask = Funcs.EnableMask()
    }
    
    let returnValue = sysEnableMask  && mappingProps.enableMask;
    /** 
     * 使用场景：编辑时没有权限设置为只读
     * 这个需求取消了
    if (returnValue && Funcs.HasMaskAuth && false === Funcs.HasMaskAuth()) {
        this.ReadOnly = true;
    }
    */
    
    return returnValue;
    // return true;
  }
 
  const toggleMask = () => {
    switchMask(!IsMasked.value)
  }
  const sysHasMaskAuth = ()=>{
    let sysHasMaskAuth = false;
    if (window.Funcs&&window.Funcs.HasMaskAuth) {
      sysHasMaskAuth = Funcs.HasMaskAuth()
    }
    return sysHasMaskAuth
  }
  const maskIconClick = ()=>{
    if(!sysHasMaskAuth()) return 
    IsMasked.value=!IsMasked.value
  }
  return {
    
    initMask,IsMasked,maskIconClick,sysHasMaskAuth
  }
}

export default useMark;
